package com.fr.report.highlight;

import com.fr.base.FCloneable;
import com.fr.base.XMLable;
import com.fr.base.xml.XMLObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.io.xml.ReportXMLUtils;
import java.util.ArrayList;
import java.util.List;

public class HighlightGroup
  implements XMLable
{
  private Highlight[] highlight_array = null;

  public HighlightGroup()
  {
  }

  public HighlightGroup(Highlight[] paramArrayOfHighlight)
  {
    this.highlight_array = paramArrayOfHighlight;
  }

  public int size()
  {
    return ((this.highlight_array == null) ? 0 : this.highlight_array.length);
  }

  public Highlight getHighlight(int paramInt)
  {
    return this.highlight_array[paramInt];
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    int i;
    HighlightGroup localHighlightGroup = (HighlightGroup)super.clone();
    if (this.highlight_array != null)
    {
      localHighlightGroup.highlight_array = new Highlight[this.highlight_array.length];
      for (i = 0; i < localHighlightGroup.highlight_array.length; ++i)
        localHighlightGroup.highlight_array[i] = ((Highlight)getHighlight(i).clone());
    }
    return localHighlightGroup;
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if (size() == 0)
      return;
    paramXMLPrintWriter.startTAG("HighlightList");
    int i = size();
    for (int j = 0; j < i; ++j)
    {
      Highlight localHighlight = getHighlight(j);
      ReportXMLUtils.writeXMLable(paramXMLPrintWriter, localHighlight, "Highlight");
    }
    paramXMLPrintWriter.end();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isAttr())
    {
      ArrayList localArrayList = new ArrayList();
      paramXMLableReader.readXMLObject(new XMLObject(this, localArrayList)
      {
        private final HighlightGroup this$0;

        public void readXML()
        {
          if ((paramXMLableReader.isChildNode()) && (paramXMLableReader.getTagName().equals("Highlight")))
          {
            Highlight localHighlight = ReportXMLUtils.readHighlight(paramXMLableReader);
            if (localHighlight != null)
              ((List)getObject()).add(localHighlight);
          }
        }
      });
      if (localArrayList.size() == 0)
        this.highlight_array = null;
      else
        this.highlight_array = ((Highlight[])localArrayList.toArray(new Highlight[localArrayList.size()]));
    }
  }
}